package com.wz.sort;

public class InsertSort {

	public static void doSort(int... args){
		for (int i = 1; i < args.length; i++) {
			for (int j = i; j > 0; j--) {
				if (args[j] < args[j-1]){
					swap(j, j - 1, args);
				} else continue;
			}
		}
	}

	private static void swap(int indexOne, int indexTwo, int... args){
		int tmp = args[indexOne];
		args[indexOne] = args[indexTwo];
		args[indexTwo] = tmp;
	}

	public static void main(String[] args) {
		int[] a = new int[]{5,2,7,44,56,2,4,-9,4,7,11,98,1};
		doSort(a);
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]+":");
		}
		System.out.println("");
	}
}